<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>部门管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <!-- <link rel="stylesheet" href="../../static/css/style.css"  media="all">-->
    <!-- <link rel="stylesheet" href="../../static/css/zTreeStyle/zTreeStyle.css" />-->
    <link rel="stylesheet" href="../../static/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <link rel="stylesheet" href="../../static/zTree_v3/css/metroStyle/metroStyle.css" type="text/css">
    <script type="text/javascript" src="../../static/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../layui/layui.all.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../static/js/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../static/js/base.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../static/js/ax.js"></script>
    <!-- <script type="text/javascript" src="../../static/js/jquery.ztree.core.js" ></script>-->
    <script type="text/javascript" src="../../static/zTree_v3/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="../../static/zTree_v3/js/jquery.ztree.excheck.js"></script>
    <script type="text/javascript" src="../../static/zTree_v3/js/jquery.ztree.exedit.js"></script>

    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="content-wrap">
        <div class="layui-row">
            <div class="layui-col-md2">
                <ul class="ztree" id="treeDemo"></ul>
                <input type="hidden" name="departmentCode" id="departmentCode">
                <input type="hidden" name="departmentName" id="departmentName">
            </div>
        </div>
    </div>
</div>

<script>
    var setting = {
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            onClick: zTreeOnClick
        }
    };

    function zTreeOnClick(e, treeId, treeNode) {
       var  departmentCode = treeNode.depCode;
       var  departmentName = treeNode.name;
        $("#departmentCode").val(departmentCode);
        $("#departmentName").val(departmentName);
    }

    $(document).ready(function () {
        ax.get({
            type: "get",
            url: schoolWebUrl+"/api/department/getDepTree",
            success: function (data) {
                $.fn.zTree.init($("#treeDemo"), setting, data.data); //加载数据
            }
        });
    });
</script>
</body>
</html>